<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <cpn></cpn>
    <cpn2></cpn2>
  </div>

  <!-- 1.分离写法 -->
  <!-- script标签,注意:类型必须是text/x-template -->
  <script type="text/x-template" id="cpn">
    <div>
      <h2>我是标题</h2>
      <p>我是内容</p>
    </div>
  </script>

  <!-- 2.template标签 -->
  <template id="cpn2">
    <div>
      <h2>我是标题ttt</h2>
      <p>我是内容</p>
    </div>
  </template>


  <script>
    // 1.注册一个全局组件(分离写法)
    Vue.component('cpn', {
      template: '#cpn'
    })
    // 
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      // 2.注册一个局部组件(分离写法)
      components: {
        cpn2: {
          template: '#cpn2'
        }
      }
    });
  </script>
</body>

</html>